package com.dnjn.happiness.system.api;

import com.dnjn.happiness.common.core.model.PositionLadderVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.dnjn.happiness.common.core.constant.SecurityConstants;
import com.dnjn.happiness.common.core.constant.ServiceNameConstants;
import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.system.api.domain.SysUser;
import com.dnjn.happiness.system.api.factory.RemoteUserFallbackFactory;
import com.dnjn.happiness.system.api.model.LoginUser;

import java.util.List;
import java.util.Map;

/**
 * 用户服务
 * 
 * @author happiness
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{

    @GetMapping("/user/getUserByEmpno/{empno}")
    R<SysUser> getUserByEmpno(@PathVariable("empno") String empno, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/user/checkUserIsManager/{userId}")
    R<Boolean> checkUserIsManager(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/selectByLimit/{page}/{pageSize}")
    R<List<SysUser>> selectByLimit(@PathVariable("page") Integer page, @PathVariable("pageSize") int pageSize,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/getUserCount")
    R<Long> getUserCount(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/user/getUserListAll")
     R<List<SysUser>> getUserListAll(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/user/getUserByUnId/{id}")
     R<SysUser> getUserByUnId(@PathVariable("id") String id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据工号姓名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/selectUserByEmpnoAndUserName/{empno}/{username}")
     R<LoginUser> selectUserByEmpnoAndUserName(@PathVariable("empno") String empno,@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
     R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
     R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户id查询用户信息
     */
    @GetMapping("/user/selectUserById/{userId}")
     R<SysUser> selectUserById(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户id查询用户信息
     */
    @GetMapping("/user/selectUserInfo/{userId}")
     R<SysUser> selectUserInfo(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询用户列表
     */
    @PostMapping("/user/selectUserList")
     R<List<SysUser>> selectUserList(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 根据岗位id获取用户列表
     * @param map
     * @return
     */
    @PostMapping("/user/getUsersByPostId")
     R<List<SysUser>> getUsersByPostId(@RequestBody Map<String, Object> map,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据职级id获取用户列表
     * @param map
     * @return
     */
    @PostMapping("/user/getUsersByPosition")
     R<List<SysUser>> getUsersByPosition(@RequestBody Map<String, Object> map,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 根据岗位id获取用户列表
     * @param userId
     * @return
     */
    @PostMapping("/user/selectUserListByDeptIdList/{userId}")
     R<List<Long>> selectUserListByDeptIdList(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/user/getUsersByDeptIdList")
     R<Long> getUsersByDeptIdList(@RequestBody List<Long> deptIdList,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/user/getCommunicationCount/{num}")
     R<Long> getCommunicationCount(@PathVariable("num") Integer num,@RequestBody List<Long> deptIdList,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/queryPositionListByDeptId/{deptId}")
      R<List<PositionLadderVO>> queryPositionListByDeptId(@PathVariable("deptId") Long deptId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/selectUserCount/{deptId}")
     R<Integer> selectUserCount(@PathVariable("deptId") Long deptId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/user/queryUserListByDeptId")
     R<List<SysUser>> queryUserListByDeptId(@RequestParam(name = "currtDeptId",required = false) Long currtDeptId, @RequestParam(name = "nickName",required = false) String nickName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user//selectUsersByLeaderId/{leaderId}")
     R<List<SysUser>> selectUsersByLeaderId(@PathVariable("leaderId") Long leaderId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户id查询用户信息
     */
    @GetMapping("/user/selectUserAndScore/{userId}")
     R<SysUser> selectUserAndScore(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
